package com.cw.japp

import grails.plugin.springsecurity.annotation.Secured;

class ChatController {
	
	static allowedMethods = [index:'POST',
                             chatRoom:'POST']
	
	def springSecurityService
	
	@Secured('permitAll')
	def chatRoom(){
		def userDetails
		def user
		if(springSecurityService.isLoggedIn()){
			userDetails = springSecurityService.principal
			user = User.get(userDetails.id);
		}else{
			user = new User();
			user.username = "Guest"
			user.firstName = "Guest"
			user.lastName = "123"
		}
		def model = User.get(params.modelId)
		[userInstance: user, modelInstance: model]
	}
}
